/*
 * BCGene.cpp
 *
 *  Created on: 29/04/2013
 *      Author: Antonio Gonzalez
 */
#include "BirthClinic/include/BCGene.h"
#include <iostream>
#include "BirthClinic/include/BCSharedData.h"

BCGene::BCGene( int from_, int dir_, int to_ )
{
	_from = from_;
	_to = to_;

	// MUTATION:
	int random = rand() % 100;
	if(random <= BCSharedData::_mutationProbability){
		int randomDir = rand() % 4;
		_dir = randomDir;
	}
	else{
		_dir = dir_;
	}
}

BCGene::BCGene( int from_, int dir_, int to_, double mutationProb_)
{
	_from = from_;
	_to = to_;

	// MUTATION:
	int random = rand() % 100;
	if(random <= mutationProb_){
		int randomDir = rand() % 4;
		_dir = randomDir;
		std::cout << "Mutation change the direction from " << dir_ << " to " << _dir << std::endl;
	}
	else{
		_dir = dir_;
	}
}

void BCGene::changeDirection(int newDir_){
	_dir = newDir_;
}

void BCGene::setFrom(int newFrom_){
	_from = newFrom_;
}

int BCGene::getDirection(){
	return _dir;
}

int BCGene::getFrom(){
	return _from;
}

int BCGene::getTo(){
	return _to;
}

void BCGene::printInfo(){
	std::cout << "From: " << _from << " To: " << _to << " Using: " << _dir << std::endl;
}

void BCGene::logInfo(){
	BCSharedData::_birthClinicLogFile << "From: " << _from << " To: " << _to << " Using: " << _dir << std::endl;
}
